<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/**
 * Class Help extends CI_Controller 
 * 反馈信息
 * @author 
 */
class Datashow extends CRUD_Controller
{
	function __construct(){
        parent::__construct();
        
    }

	public function index()
	{
		$vdata['title'] = '数据统计';
		$year=date("Y",time());
		$table = $this->db->dbprefix.'acount';
		for ($i=1; $i <13 ; $i++) { 			
			$i1=$i+1;
			$start=strtotime($year."-".$i."-1");
			$end=strtotime($year."-".$i1."-1");
			if($i==12){
				$t_year=$year+1;
				$end=strtotime($t_year."-1-1");
			}
			//会员
			$s_where=" where timeline>=".$start." and timeline <".$end;
	        $sql1="SELECT  COUNT(id) AS num FROM ".$table . $s_where;
	        $num_dc[$i]=$this->db->query($sql1)->row_array();	      
		}


		$num_dcs=0;
		foreach ($num_dc as $key => $v) {
			if($key==1){
				$num_dcs=$v['num'];
			}else{
				$num_dcs.=",".$v['num'];
			}
			$num_dcs_count[]=$v['num'];		
		}
		$vdata['num_dcs']=$num_dcs;
		
		$this->_vdata($vdata);
		$this->load->view('inc_header.php',$vdata);
		$this->load->view('datashow_index.php');
		$this->load->view('inc_footer.php');
	}


	public function search()
	{
		$vdata['title'] = '数据统计';
		$table = $this->db->dbprefix.'acount';
		$year=$this->input->get('years');
        for ($i=1; $i <13 ; $i++) { 
			$i1=$i+1;
			$start=strtotime($year."-".$i."-1");
			$end=strtotime($year."-".$i1."-1");
			if($i==12){
				$t_year=$year+1;
				$end=strtotime($t_year."-1-1");
			}
			//融资项目
			//地产
			$s_where=" where timeline>=".$start." and timeline <".$end;
	        $sql1="SELECT  COUNT(id) AS num FROM ".$table . $s_where;
	        $num_dc[$i]=$this->db->query($sql1)->row_array();
	        
	      
		}
		foreach ($num_dc as $key => $v) {
			if($key==1){
				$num_dcs=$v['num'];
			}else{
				$num_dcs.=",".$v['num'];
			}
			$num_dcs_count[]=$v['num'];		
		}
		$num_dcs_sum=0;
		if(!empty($num_dcs_count)){$num_dcs_sum=array_sum($num_dcs_count);}
		$vdata['num_dcs']=$num_dcs;
		$vdata['num_dcs_sum']=$num_dcs_sum;
		$vdata['getnf']=$year;




		$this->_vdata($vdata);

		$this->load->view('inc_header.php',$vdata);
		$this->load->view('datashow_index.php');
		$this->load->view('inc_footer.php');
	}
	
	 
    
    
}